package cn.kgc.ffzw.day22.homework;

import java.util.*;

public class Orders {
    public static void main(String[] args) {
        Map<Integer,Shopping>  map=new HashMap<Integer, Shopping>();

        for (int i = 0; i <3 ; i++) {
            Shopping shop=new Shopping("苹果"+(i+10),5555+(i*500),2);
            map.put(i+1,shop);
        }
        Set<Integer> keys=map.keySet();

        for (Object obj: keys) {
            Shopping s=  map.get(obj);
            System.out.print("单号"+obj+"\t商品："+s.name+
                    //"\t商品单价："+s.price+
                    //"\t商品数量："+s.count+
                    "\t总价："+s.totalPrice+"\n");
        }

        //values 打印购物车此信息
        Collection<Shopping> values=map.values();
        for (Shopping shop: values) {
            System.out.println("商品名："+shop.getName()+"\t"+
                    "商品价格："+shop.getPrice()+"\t"+
                    "商品数量："+shop.getCount()+"\t"+
                    "商品总价："+shop.getTotalPrice()+"\n");
        }

        //entryset遍历订单信息

        Iterator<Map.Entry<Integer,Shopping>> iterator=map.entrySet().iterator();
        while(iterator.hasNext()){
            Map.Entry<Integer,Shopping> entries=iterator.next();
            Integer i=entries.getKey();
            Shopping s=entries.getValue();
            System.out.print("单号"+i+"\t商品："+s.name+
                    //"\t商品单价："+s.price+
                    //"\t商品数量："+s.count+
                    "\t总价："+s.totalPrice+"\n");
        }




    }



}
